package name.zxw.rabbitmq.dead;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;

import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

/**
 * @author zhangxinwang
 * @date 2022/6/23 17:58
 */
public class MyPublisher {

    private static final String NORMAL_EXCHANGE = "normal_exchange";
    private static final String NORMAL_ROUTING_KEY = "zhangsan";

    public static void main(String[] args) throws Exception{
        ConnectionFactory factory = new ConnectionFactory();
        Channel channel = factory.newConnection().createChannel();

        AMQP.BasicProperties properties = new AMQP.BasicProperties().builder().expiration("10000").build();

        for (int i = 0; i < 30; i++) {
            channel.basicPublish(NORMAL_EXCHANGE,NORMAL_ROUTING_KEY,null,String.valueOf(i).getBytes(StandardCharsets.UTF_8));
            TimeUnit.SECONDS.sleep(1);
        }



    }

}
